package com.eccg.shopping.qrcode;

import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.eccg.shopping.R;


public class DigilinxActivity extends Activity {
	
	
	
	TextView productText;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		 setContentView(R.layout.test);
		  findViewById(R.id.scan_product).setOnClickListener(mScanProduct);
		  productText= (TextView) findViewById(R.id.TextView01);
		
	}
	@Override
	protected void onResume() {
		super.onResume();
		 productText.setText($contents);
	}
	
	 public final Button.OnClickListener mScanProduct = new Button.OnClickListener() {
		    public void onClick(View v) {
		      Intent intent = new Intent("com.eccg.shopping.SCAN");
		      startActivityForResult(intent, 0);
		    }
	};

	public static String $contents;
	 @Override
	  public void onActivityResult(int requestCode, int resultCode, Intent intent) {
	    if (requestCode == 0) {
	      if (resultCode == RESULT_OK) {
	        String contents = intent.getStringExtra("SCAN_RESULT");
	        String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
//	        showDialog(R.string.result , contents);
	        $contents = contents;
	        productText.setText($contents);
	        
	      } else if (resultCode == RESULT_CANCELED) {
//	        showDialog(R.string.result, getString(R.string.result_failed_why));
	      }
	    }
	  }
	 
//	 private void showDialog(int title, String message) {
//		    CustomDialog.Builder builder = new CustomDialog.Builder(this);
//		    builder.setImage(R.drawable.warning_icon);
//		    builder.setTitle(title);
//		    builder.setMessage(message);
//		    builder.setPositiveButton("确定", new OnClickListener() {
//				
//				@Override
//				public void onClick(DialogInterface dialog, int which) {
//					dialog.dismiss();
//				}
//			});
//		    builder.create().show();
//	 }

}
